/**
 * 初始化分类统计总量
 *showFlStatisticsTest--测试效果
 *showFlStatistics--请求获取数据
 */
cqrbdp.showFlStatisticsTest1 = function() {
     var FlStatisticsItems1 = [{
        desc: "新浪微博",
        count: 90,
        add:parseInt(Math.random()*612)+612,
        del:parseInt(Math.random()*187)+187,
        icon: 'wb-icon'
    }, {
        desc: "腾讯微博",
        count: 30,
        add:parseInt(Math.random()*30)+28,
        del:parseInt(Math.random()*153)+154,
        icon: 'txwb-icon'
    }, {
        desc: "微信公众号",
        count: 90,
        add:parseInt(Math.random()*430)+433,
        del:parseInt(Math.random()*432)+435,
        icon: 'wx-icon'
    }, {
        desc: "新闻客户端",
        count: 90,
        add:parseInt(Math.random()*1)+2,
        del:parseInt(Math.random()*87)+86,
        icon: 'khd-icon'
    }, {
        desc: "音视频",
        count: 90,
        add:parseInt(Math.random()*2)+2,
        del:parseInt(Math.random()*56)+55,
        icon: 'ysp-icon'
    }, {
        desc: "境外新闻",
        count: 90,
        add:parseInt(Math.random()*15)+49,
        del:parseInt(Math.random()*65)+65,
        icon: 'xw-icon'
    }, {
        desc: "国内新闻",
        count: 90,
        add:parseInt(Math.random()*6)+67,
        del:656,
        icon: 'gnxw-icon'
    }, {
        desc: "国内博客",
        count: 90,
        add:parseInt(Math.random()*3)+22,
        del:parseInt(Math.random()*65)+67,
        icon: 'gnbk-icon'
    }, {
        desc: "国内论坛",
        count: 60,
        add:parseInt(Math.random()*34)+39,
        del:parseInt(Math.random()*768)+788,
        icon: 'gnlt-icon'
    }];

    var target = $("#flCount2"), //数据显示区域
        endVal, //显示值
        queryState = false, //是否可以进行下次查询
        itemIndex = 0, //显示的序号
        countup,
        timeIntever = cqrbdp.flFreshTimeInterval; //查询时间间隔;
    var target1 = $("#addCount"), //数据显示区域
        endVal1, //显示值
        queryState = false, //是否可以进行下次查询
        itemIndex = 0, //显示的序号
        countup1,
        timeIntever = cqrbdp.flFreshTimeInterval; //查询时间间隔;
    var target2 = $("#delCount"), //数据显示区域
        endVal2, //显示值
        queryState = false, //是否可以进行下次查询
        itemIndex = 0, //显示的序号
        countup2,
        timeIntever = cqrbdp.flFreshTimeInterval; //查询时间间隔;

    var options = { //数据动态显示的配置信息
        useEasing: true, // toggle easing
        useGrouping: true, // 1,000,000 vs 1000000
        separator: '<span class="fl-unit">万</span>', // character to use as a separator
        separator2: '<span class="fl-unit">亿</span>',
        decimal: '.', // character to use as a decimal
    }
    $('#addCount').html(FlStatisticsItems1[0].add);
    $('#delCount').html(FlStatisticsItems1[0].del);
    $(".int-fl-item span").html(FlStatisticsItems1[0].desc); //显示描述
    $(".int-fl-icon").find("." + FlStatisticsItems1[0].icon).fadeIn("slow"); //显示图标
    //请求某分类统计量
    endVal = FlStatisticsItems1[0].count;
    endVal1 = FlStatisticsItems1[0].add;
    endVal2 = FlStatisticsItems1[0].del;
    countup = new CountUp(target[0], 0, endVal, 0, 2, options);
    countup1 = new CountUp(target1[0], 0, endVal1, 0, 2, options);
    countup2 = new CountUp(target2[0], 0, endVal2, 0, 2, options);
    countup.start();
    countup1.start();
    countup2.start();
    queryState = true;
    setInterval(updateFlStatistics1, timeIntever);

    function updateFlStatistics1() {
        if (!queryState) {
            return;
        }
        queryState = false;

        var lastIndex = itemIndex;
        if (itemIndex < FlStatisticsItems1.length - 1) {
            itemIndex += 1;
        } else {
            itemIndex = 0;
        }

        endVal = FlStatisticsItems1[itemIndex].count;
        endVal1 = FlStatisticsItems1[itemIndex].add;
        endVal2 = FlStatisticsItems1[itemIndex].del;
        queryState = true;
        var desc = FlStatisticsItems1[itemIndex].desc;
        var icon = FlStatisticsItems1[itemIndex].icon;
        $(".int-fl-item span").html(desc);
        $('#addCount').html(FlStatisticsItems1[itemIndex].add);
        $('#delCount').html(FlStatisticsItems1[itemIndex].del);
        $(".int-fl-icon").find("." + FlStatisticsItems1[lastIndex].icon).fadeOut("slow", function() {
            $(".int-fl-icon").find("." + FlStatisticsItems1[itemIndex].icon).fadeIn("slow");
        });
        countup.update(endVal);
        countup1.update(endVal1);
        countup2.update(endVal2);
    }
}

cqrbdp.showFlStatistics1 = function() {
    var FlStatisticsItems1 = [{
        desc: "新浪微博",
        icon: 'wb-icon'
    }, {
        desc: "腾讯微博",
        icon: 'txwb-icon'
    }, {
        desc: "微信公众号",
        icon: 'wx-icon'
    }, {
        desc: "新闻客户端",
        icon: 'khd-icon'
    }, {
        desc: "音视频",
        icon: 'ysp-icon'
    },{
        desc: "境外新闻",
        icon: 'xw-icon'
    },
    {
        desc: "国内新闻",
        icon: 'gnxw-icon'
    },
    {
        desc: "国内博客",
        icon: 'gnbk-icon'
    },
    {
        desc: "国内论坛",
        icon: 'gnlt-icon'
    },];

    var target = $("#flCount2"), //数据显示区域
        endVal, //显示值
        queryState = false, //是否可以进行下次查询
        itemIndex = 0, //显示的序号
        countup,
        timeIntever = cqrbdp.flFreshTimeInterval; //查询时间间隔;
    var target1 = $("#addCount"), //数据显示区域
        endVal1, //显示值
        queryState = false, //是否可以进行下次查询
        itemIndex = 0, //显示的序号
        countup1,
        timeIntever = cqrbdp.flFreshTimeInterval; //查询时间间隔;
    var target2 = $("#delCount"), //数据显示区域
        endVal2, //显示值
        queryState = false, //是否可以进行下次查询
        itemIndex = 0, //显示的序号
        countup2,
        timeIntever = cqrbdp.flFreshTimeInterval; //查询时间间隔;

    var options = { //数据动态显示的配置信息
        useEasing: true, // toggle easing
        useGrouping: true, // 1,000,000 vs 1000000
        separator: '<span class="fl-unit">万</span>', // character to use as a separator
        separator2: '<span class="fl-unit">亿</span>',
        decimal: '.', // character to use as a decimal
    }
    $('#addCount').html(FlStatisticsItems1[0].add);
    $('#delCount').html(FlStatisticsItems1[0].del);
    $(".int-fl-item span").html(FlStatisticsItems1[0].desc); //显示描述
    $(".int-fl-icon").find("." + FlStatisticsItems1[0].icon).fadeIn("slow"); //显示图标

    /**
     * 请求某分类统计量
     * 使用统计互联网采集分类数据总量接口
     *         参数直接使用itemIndex
     */
    $.get('url', {
        class: itemIndex
    }, function(json) {
        endVal = json.result;
        endVal1 = json.result;
        endVal2 = json.result;
        countup = new CountUp(target[0], 0, endVal, 0, 2, options);
        countup1 = new CountUp1(target1[0], 0, endVal1, 0, 2, options);
        countup2 = new CountUp2(target2[0], 0, endVal2, 0, 2, options);
        countup.start();
        countup1.start();
        countup2.start();
        queryState = true;
        setInterval(updateFlStatistics1, timeIntever);
    });

    function updateFlStatistics1() {
        if (!queryState) {
            return;
        }
        queryState = false;

        var lastIndex = itemIndex;
        if (itemIndex < FlStatisticsItems1.length - 1) {
            itemIndex += 1;
        } else {
            itemIndex = 0;
        }

        $.get('url', '{data}', function(json) {
            endVal = json.result; //取值
            endVal1 = json.result; //取值
            endVal2 = json.result; //取值
            queryState = true;
            var desc = FlStatisticsItems1[itemIndex].desc;
            var icon = FlStatisticsItems1[itemIndex].icon;
            $(".int-fl-item span").html(desc);
            $('#addCount').html(FlStatisticsItems1[itemIndex].add);
            $('#delCount').html(FlStatisticsItems1[itemIndex].del);
            $(".int-fl-icon").find("." + FlStatisticsItems1[lastIndex].icon).fadeOut("slow", function() {
                $(".int-fl-icon").find("." + FlStatisticsItems1[itemIndex].icon).fadeIn("slow");
            });
            countup.update(endVal);
            countup1.update(endVal1);
            countup2.update(endVal2);
        });
    }
}


    